<template>
<table>
    <tr>
        <td>用户名</td>
        <td><input type="text" v-model="data.Uname"></td>
    </tr>
    <tr>
        <td>密码</td>
        <td><input type="password" v-model="data.Upwd"></td>
    </tr>
    <tr>
        <td><input type="button" value="注册" @click="AddUlgin"></td>
    </tr>
</table>
</template>
<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import {useRouter} from 'vue-router';
const router=useRouter();
const data=ref(
    {
        Uname:'',
        Upwd:'',

    }
)
const AddUlgin=()=>{
    axios.post('https://localhost:44368/api/Lx/AddUlogin',
        {
            Uname:data.value.Uname,
            Upwd:data.value.Upwd
        }
    ).then(res=>{
        if(res.data==-1){
            alert('用户名已存在')
        }
        else if(res.data>0){
            alert('注册成功')
            router.push('/Ulogin')
        }
        else{
            alert('注册失败')
        }
    }).catch(err=>{
        console.log(err);
    })
}


</script>